package cn.ffcs.organ.service;

import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

import cn.ffcs.base.service.BaseService;
import cn.ffcs.organ.model.Organization;

/**
 * 组织服务实现类<br/>
 * <table>
 * <tr>
 * <td>负责人/principal:</td>
 * <td colspan="2">liuzhh</td>
 * <tr>
 * <td>修改记录/revision:</td>
 * <td colspan="2"></td>
 * </tr>
 * <tr>
 * <td>日期:</td>
 * <td>修改人:</td>
 * <td>修改说明:</td>
 * </tr>
 * <tr>
 * <td></td>
 * <td></td>
 * <td></td>
 * </tr>
 * </table>
 * @author liuzhh
 * @version $Id$
 */
public class OrganizationService<O extends Organization> extends BaseService<O>
        implements IOrganizationService<O>
{
    /**
     * {@inheritDoc}
     */
    public List<O> findAllCorps(){
        Criterion cond =Restrictions.eq("orgType","CORP");
        return super.findByAndOrder(cond, "disport", "ASC");
    }
    
    /**
     * {@inheritDoc}
     */
    public List<O> findAllDepts(){
        Criterion cond = Restrictions.eq("orgType","DEPT");
        return super.findByAndOrder(cond, "orderBy", "ASC");
    }
    
    /**
     * {@inheritDoc}
     */
    public List<O> findAllDeptsBy(int corpID){
        Criterion cond1 =Restrictions.eq("superior",Integer.toString(corpID));
        Criterion cond2 = Restrictions.eq("orgType","DEPT");
        Criterion cond=Restrictions.and(cond1, cond2);
        return super.findByAndOrder(cond, "disport", "ASC");
    }

    /**
     * 
     * {@inheritDoc}
     */
    public List<O> findAllOrgsBy(int orgID){
        Criterion cond =Restrictions.eq("superior",Integer.toString(orgID));
        return super.findByAndOrder(cond, "disport", "ASC");         
    }


}
